FROM node:18-alpine

# Install dependencies for Puppeteer
RUN apk add --no-cache libxshmfence1 fontconfig ttf-freefont

WORKDIR /app

# Copy package files and install dependencies
COPY package*.json ./
RUN npm install

# Copy source code
COPY . .

# Create directory for PDF storage
RUN mkdir -p /app/pdfs && chown node:node /app/pdfs

USER node

EXPOSE 3000
CMD ["node", "server.js"]
